package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 协作操作实体类 - 用于记录编辑历史
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("collaboration_operation")
@Schema(description = "协作操作实体")
public class CollaborationOperation extends BaseEntity {

    /**
     * 操作ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "操作ID", example = "1")
    private Long id;

    /**
     * 会话ID
     */
    @TableField("session_id")
    @Schema(description = "会话ID", example = "1")
    private Long sessionId;

    /**
     * 用户ID
     */
    @TableField("user_id")
    @Schema(description = "用户ID", example = "1")
    private Long userId;

    /**
     * 操作内容ID（MongoDB中的_id）
     */
    @TableField("content_id")
    @Schema(description = "操作内容ID", example = "60a6c59c8f7d587a10b0c1a2")
    private String contentId;

    /**
     * 操作类型：0-插入，1-删除，2-替换，3-格式化，4-注释
     */
    @TableField("op_type")
    @Schema(description = "操作类型：0-插入，1-删除，2-替换，3-格式化，4-注释", example = "0")
    private Integer opType;

    /**
     * 版本号
     */
    @TableField("version")
    @Schema(description = "版本号", example = "1")
    private Integer version;

    @Column(name = "created_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 